package com.example.springbootsenior.RedisCache.controller;

import com.example.springbootsenior.RedisCache.entry.po.Employee;
import com.example.springbootsenior.RedisCache.service.EmployeeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @classDesc: 功能描述:cache学习
 * @author: 李明杰
 * @date: 2021/11/18 21:25
 * @copyright
 */
@RestController
public class EmployeeController {
    @Resource(name = "employeeService")
    EmployeeService employeeService;

    @GetMapping("/cache/select/{id}")//restful此处无#
    public Object select(@PathVariable String id) {
        return employeeService.getById(id);
    }

    @GetMapping("/cache/del/{id}")
    public Object delete(@PathVariable String id) {
        return employeeService.removeById(id);
    }

    @PostMapping("/cache/update")
    public Object update(Object o) {
        return employeeService.updateById((Employee) o);
    }

    @GetMapping("/cache/emp/{lastName}")
    public Employee getEmpByLastName(@PathVariable("lastName") String lastName) {
        return employeeService.getEmpByLastName(lastName);
    }
}
